package com.zhx.basis.集合;

import java.util.Arrays;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {

        //基础数据类型结果都是1 包装数据类型才正常


//        String[] arr = {"1","2","3"};
//        List list = Arrays.asList(arr);
//        System.out.println(list.size());
//
//        int[] arr1 = {1, 2, 3};
//        List list1 = Arrays.asList(arr1);
//        System.out.println(list1.size());

//        double[] arr2 = {1, 2, 3};
//        List list2 = Arrays.asList(arr2);
//        System.out.println(list2.size());

//        float[] arr3 = {1, 2, 3};
//        List list3 = Arrays.asList(arr3);
//        System.out.println(list3.size());
//
//
//
//        //解决方案1：使用包装类型
//        Integer[] integerArr = {1, 2, 3};
//
//
//        //解决方案2：流包装
//        int[] arr1 = {1, 2, 3};
//        List collect = Arrays.stream(arr1).boxed().collect(Collectors.toList());



        //arrays并发修改错误，因为modcount发生改变
//        List<String> names = new ArrayList<String>() {{
//            add("one");
//            add("two");
//            add("three");
//
//        }};
//        List strings = names.subList(0, 1);
//
//        names.add("four");
//
//        System.out.println(strings.toString());
//        Exception in thread "main" java.util.ConcurrentModificationException



        int[][] arrays = {{1,2}, {1}, {3,4}, {4,5}};
        boolean[] overlap = new boolean[arrays.length];

        for (int i = 0; i < arrays.length; i++) {
            for (int j = i+1; j < arrays.length; j++) {
                if (Arrays.toString(arrays[i]).contains(Arrays.toString(arrays[j]))) {
                    overlap[i] = overlap[j] = true;
                }
            }
        }

        for (int i = 0; i < arrays.length; i++) {
            if (overlap[i]) {
                System.out.println("Array " + (i+1) + " has overlap:");
                System.out.println(Arrays.toString(arrays[i]));
            }
        }




//
//
        Scanner sc = new Scanner(System.in);
//        String s = sc.nextLine();
//
//        String[] split = s.substring(1, s.length() - 1).split(",");
//
//        bubbleSort(split);
//        StringJoiner joiner=new StringJoiner(",","[","]");
//        for (String s1 : split) {
//            joiner.add(s1);
//        }
//
//        System.out.println(joiner.toString());

    }

    //冒泡排序
    static void bubbleSort(String array[]) {
        int size = array.length;

        for (int i = 0; i < size - 1; i++)
            for (int j = 0; j < size - i - 1; j++)
                if (Integer.valueOf(array[j]) > Integer.parseInt(array[j+1])) {
                    int temp = Integer.valueOf(array[j]);
                    array[j] = array[j + 1];
                    array[j + 1] = temp+"";
                }
    }



}
